/*****************************************************************************************************
*       SRLOS Team
*@filename:     k_common_asm.h
*@brief   :     this file defines some common kernel using macros
*@author  :     bloceanc
*@note    :     we need some asm function codes
*@comment :
*@datetime:
*****************************************************************************************************/
#ifndef _K_COMMEN_ASM_H_
#define	_K_COMMEN_ASM_H_


/*
 * @brief Disable Interrupt
 * should close interrupt when allocate pages or other things
 * Just Disable IRQ interrupt, except FIQ
 */
#define	K_MEM_DISABLE_INTERRUPT	{	\
	__asm__(	\
		"STMFD R13!, {R0}\n\t"	\
		"MRS R0, CPSR\n\t"	\
		"ORR R0, R0, #0x80\n\t"	\
		"MSR CPSR_c, R0\n\t"	\
		"LDMFD R13!, {R0}\n\t"	\
	);	\
}

/**@brief Enable Interrupt */
// enable interrupt after allocate or other things
#define K_MEM_ENABLE_INTERRUPT {	\
	__asm__(	\
		"STMFD R13!, {R0}\n\t"	\
		"MRS R0, CPSR\n\t"	\
		"ADD R0, R0, #0xFFFFFF7F\n\t"	\
		"MSR CPSR_c, R0\n\t"	\
		"LDMFD R13!, {R0}\n\t"	\
	);	\
}

#endif
